package lyq.spec.edu.week12_home02;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class ActivityThird extends AppCompatActivity {
    private List<Wechat3> mlsit = new ArrayList<Wechat3>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_third);

        //初始化List数据

        initwechats();

        //初始化RecyclerView

        RecyclerView recyslerview = (RecyclerView) findViewById(R.id.recycler_view);

        //创建LinearLayoutManager 对象 这里使用 LinearLayoutManager 是线性布局的意思

        LinearLayoutManager layoutmanager = new LinearLayoutManager(this);
        layoutmanager.setOrientation(LinearLayoutManager.HORIZONTAL);


        //设置RecyclerView 布局

        recyslerview.setLayoutManager(layoutmanager);

        //设置Adapter

        WeChatAdpater3 adapter = new WeChatAdpater3(mlsit);

        recyslerview.setAdapter(adapter);

        }


                private void initwechats() {

                    for (int i = 0; i < 5; i++) {

                        Wechat3 wechat31 = new Wechat3("济南 7.77..."  , R.drawable.a9);

                        mlsit.add(wechat31);

                        Wechat3 wechat32 = new Wechat3("我是腾腾爸"  , R.drawable.a8);

                        mlsit.add(wechat32);

                        Wechat3 wechat33 = new Wechat3("川幼应用..."  , R.drawable.a7);

                        mlsit.add(wechat33);

                        Wechat3 wechat34 = new Wechat3("交易军师"  , R.drawable.a6);

                        mlsit.add(wechat34);
                    }

    }
}


